using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace DataAccess
{
    public class tbUsers : Popular
    {

        public int UserID { get; set; }
        public string UserName { get; set; }
        public string FullName { get; set; }
        public DateTime? Birthday { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
        public string Mobile { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
        public DateTime? CreatedDate { get; set; }
        public DateTime? LastLogin { get; set; }
        public bool? IsAdmin { get; set; }
        public bool? Active { get; set; }
        public string Note { get; set; }
        //public int? ClassID { get; set; }
        public string ResetCode { get; set; }
        public DateTime? DeadlineReset { get; set; }

        Common<tbUsers> cm = new Common<tbUsers>();
        public bool Insert(Popular b)
        {
            return cm.Insert(b as tbUsers, "sp_tbUsers_Insert");
        }
        public bool Update(Popular b)
        {
            return cm.UpDate(b as tbUsers, "sp_tbUsers_Update");
        }
        public bool Delete(object b)
        {
            return cm.Delete(b, "sp_tbUsers_Delete");
        }
        public IDataReader Select_ID(object b)
        {
            return cm.Select_ID(b, "sp_tbUsers_SelectByID");
        }

        public tbUsers GetByUserName(object b)
        {
            return Core.CBO.FillObject<tbUsers>(Core.SqlDataProvider.Instance.ExecuteReader("sp_tbUsers_GetByUserName", b));
        }
        public tbUsers GetByEmail(object b)
        {
            return Core.CBO.FillObject<tbUsers>(Core.SqlDataProvider.Instance.ExecuteReader("sp_tbUsers_GetByEmail", b));
        }

        public tbUsers GetByResetCode(object b)
        {
            return Core.CBO.FillObject<tbUsers>(Core.SqlDataProvider.Instance.ExecuteReader("sp_tbUsers_GetByResetCode", b));
        }

        public tbUsers Select_ID(object[] b)
        {
            return Core.CBO.FillObject<tbUsers>(Core.SqlDataProvider.Instance.ExecuteReader("sp_tbUsers_SelectByID2", b));
        }
        public IDataReader Select_Name(object b)
        {
            return cm.Select_Name(b, "sp_tbUsers_SelectByName"); 
        }
        public IDataReader SelectAll()
        {
            return cm.Select_All("sp_tbUsers_SelectAll");
        }
        public List<tbUsers> SelectAllToList()
        {
            return cm.SelectAll<tbUsers>("sp_tbUsers_SelectAll");
        }
    }
}